<?php defined('IN_IA') or exit('Access Denied');?><!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/css/dka.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo WEB_RESOURCE;?>/lib/weui/weui.min.css">
		<title><?php  echo $list['active_name'];?></title>
		<script type="text/javascript" src="<?php echo WEB_RESOURCE;?>/js/jquery.min.js"></script>

	</head>

	<body>
		<div class="header">
			<img src="<?php  echo tomedia($list['cover_img'])?>" />
			<?php  if($time>$list['end_time']) { ?> 
			<div class="end">
				
				<p>活动已结束</p>
			</div>
			<?php  } else if($time<$list['start_time']) { ?>
			<div class="end">
				<p>活动未开始</p>
			</div>

			<?php  } else { ?>
			<div class="end">
				<div class="end">
					<div class="end-left">
						<p class="end-1">
							<?php  echo $list['group_num'];?>人团
						</p>
						&ensp;
						<p class="end-2">
							<span class="jia">￥</span><span class="jia-1"><?php  echo $list['group_price'];?></span>
						</p>
						&ensp;
						<p class="end-3">
							￥<?php  echo $list['personal_price'];?>
						</p>
					</div>
	
					<div class="end-right">
						<div class="djs">
							<p>距离拼团结束还剩：</p>
							<span id="count">
							<!-- <span class="viewtime-day"></span>天<span class="viewtime-hour"></span>时<span class="viewtime-minute"></span>分<span class="viewtime-second"></span>秒</span> -->
						</div>
					</div>
				</div>
			</div>
			<?php  } ?>
			<div class="rs">
				已有<?php  echo $count_list['count'];?>人参加团购
			</div>

			<div class="dong">
				<ul class="ul">
					<?php  if(is_array($user_list)) { foreach($user_list as $item) { ?>
					<li>
						<div class="img"><img src="<?php  echo userinfo($item['openid'])['avatar']?>" />
							<h5><?php  echo userinfo($item['openid'])['nickname']?></h5>
						</div>
					</li>
					<?php  } } ?>
				</ul>
			</div>
			<div class="lll">
				已有<?php  echo $count_list['group_count'];?>团/浏览量：<?php  echo $list['browse_num'];?>
			</div>
		</div>

		<!-- 富文本内容 -->
		<div class="body">
			<?php  echo $list['desc'];?>
		</div>
		<div class="footer"></div>

		<div class="tab">
			<div id="zhe"></div>
			<div id="zhe1"></div>
			<div class="left">
				<div class="pic">
					<img id="pic" src="<?php echo WEB_RESOURCE;?>/images/dka/tel.png">
				</div>
				<p class="kf">客服</p>
			</div>

			<div class="middle">
				<div class="pic">￥<?php  echo $list['personal_price'];?></div>
				<p class="gm">单人购买</p>
			</div>

			<div class="right">
				<div class="pic">￥<?php  echo $list['group_price'];?></div>
				<p class="ping1">我要开团</p>

			</div>

			<!-- 分享 -->
			<div id="share" style="display:none">
				<img class="fx_pic" src="<?php echo WEB_RESOURCE;?>/images/dka/fx.png" />
				<div class="fx">
					<div class="fx_text">您已报名成功<br>
						点击右上角分享给你的好友
					</div>
					
					<div class="fx_tb">
						<img id="fx" src="<?php echo WEB_RESOURCE;?>/images/dka/share1.png" />
						<div class="fx_fs">-------分享方式--------</div>
						
						<div id="fx_wx" class="fx_wx">
							<img src="<?php echo WEB_RESOURCE;?>/images/dka/share3.png" />
							<p>微信好友</p>
							
						</div>
						
						<div id="fx_py" class="fx_py">
							<img src="<?php echo WEB_RESOURCE;?>/images/dka/share4.png" />
							<p>朋友圈</p>	
						</div>
						<div id="fx_qx" class="fx_qx">取消</div>
					</div>
				</div>
			</div>
		
		
			<div class="fx_ewm">
			<div id="ewm" class="ewm">
				<img src="<?php  echo web2app_url('main',['et'=>'qrcode', 'actid'=>$list['id'], 'openid'=>$openid])?>" />
				<div class="fx_yq" style="padding-bottom:8px">
					长按识别二维码进入活动
				</div>
			</div>
			<div class="help">长按图片保存，发朋友圈邀请好友帮忙</div>
			</div>
		</div>

		

		<!--客服弹窗-->
		<div id="tan">
			<ul>
				<a href="tel:<?php  echo $list['service_mobile'];?>">
					<li>
						呼叫
					</li>
				</a>
				<hr />
				<li>复制</li>
				<hr />
				<li>添加到手机通讯录</li>
			</ul>

		</div>

		<div class="dan" id="dan">
			<div class="top">
				<div class="top1">
					<?php  echo $list['active_name'];?>
				</div>
				<div class="top2">
					<p>已有<?php  echo $count_list['group_count'];?>人参团</p>
					<p>购买人数<?php  echo $count_list['count'];?>人</p>
				</div>
			</div>
			<form action="<?php  echo web2app_url('main',['et' => 'pay'])?>" method="POST" id="form" name="form">
				<div class="zh">
					<div class="shop">
						单独购买价￥<?php  echo $list['personal_price'];?>
					</div>
					<div class="ping">
						我要开团.<?php  echo $list['group_num'];?>人拼团价￥<?php  echo $list['group_price'];?>
					</div>
				</div>
				<div class="foot">
					<input type="hidden" name="buy_type" class="buy_type"/>
					<input type="hidden" name="act_id" value="<?php  echo $list['id'];?>"/>
					<input type="hidden" name="res" id="res" value="<?php  echo $res['openid'];?>">
					<input type="hidden" name="share_openid" id="share_openid" value="<?php  echo $share_openid;?>">

					<input type="text" name="baby_name" placeholder="请输入用户姓名" />
					<input type="text" name="mobile" placeholder="请输入手机号码" />

					<?php  if($time>$list['end_time']) { ?> 

					<input type="button" value="活动已结束" />
					<?php  } else if($time<$list['start_time']) { ?>
					<input type="button" value="活动未开始" />
					<?php  } else { ?>
					<button type="submit" id="bao" />支付&nbsp;<?php  echo $list['pay_price'];?>&nbsp;元报名</button>
					<?php  } ?>

				</div>
			</form>
		</div>

		<div class="music">
			<img class="ms" id="music" src="<?php echo WEB_RESOURCE;?>/images/dka/music.png" />
		</div>

		<audio id="bgm"  autoplay="true" loop="loop" src="<?php  echo tomedia($list['bg_music']);?>">
			你的浏览器版本太低，不支持audio标签
		</audio>

		<!-- 指示文字 -->
		<img class="fx-1" src="<?php echo WEB_RESOURCE;?>/images/fenxiao11.png" />	
		
		<?php  if($list['skill_status'] === 'on') { ?>

			<!-- 图标 -->
			<img class="hb" src="<?php echo WEB_RESOURCE;?>/images/hongbao.png" />

		<?php  } ?>

      	<!--提示框 -->
        <div class="hb1" id="hb1" style="border-radius: 10px">
        	
			
			<!-- <div class="weui-mask"></div>
		    <div class="weui-dialog">
		        <div class="weui-dialog__hd"><strong class="weui-dialog__title">获奖信息</strong></div>
		        <div class="weui-dialog__bd" id="showtext"></div>
		        <div class="weui-dialog__ft">
		            <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
		        </div>
		    </div> -->

        </div>

		<script>

			$(function() {
				$('#form').on('submit', function() {

					$.post($(this).prop('action'), $('#form').serialize(), function(res) {
						if(res.errno == 0) {
							location.href=res.data.url;
							
						} else {
							alert(res.message);
							if(res.data.url) {
								location.href=res.data.url;
							}
						}
					})
					return false;
				});

				$.get("<?php  echo web2app_url('Main', ['et'=>'updateTime', 'share_openid'=>$share_view_openid, 'act_id'=>$list['id']])?>")				
			})
			
			
			$(function() {
				var people =312;

				var one = people>=1000?Math.floor(people/1000%10):0;
				var two = people>=100?Math.floor(people/100%10):0;
				var three = people >=10?Math.floor(people/10%10):0;
				var four = Math.floor(people%10);

				$('#th').html(one);
				$('#hu').html(two);
				$('#ten').html(three);
				$('#yi').html(four);
				
				$('.left').click(function() {
					$('#zhe1,#tan').show();
				
				});
				$('#zhe').click(function() {
					$('#zhe,#tan,#dan,#share,.fx_ewm,#hb1').hide();
					
				});
				$('#zhe1').click(function() {
					$('#zhe1,#dan,#tan,#share,.fx_ewm').hide();
					
				});

				var res = $('#res').val();
				$('.middle').click(function() {
					if (!res) {
						$('#zhe1').show();
						$('.dan').slideDown();

					} else {
						$('#share').css('display','block');
					}
				});
				$('#zhe').click(function() {
					$('#zhe').hide();
					$('.dan').slideUp();
				});

				$('.right').click(function() {
					if (!res) {
						$('#zhe').show();
						$('.dan').slideDown();
					} else {
						$('#share').show();
					}
				});
				$('#zhe').click(function() {
					$('#zhe').hide();
					$('.dan').slideUp();
				});

				$('.shop').click(function() {
					$('.buy_type').val('personal');

					$(this).css({
						"background-color": "yellow",
						"color": "red"
					}).siblings().css({
						"background": "none",
						"color": "white"
					});

				});

				$('.ping').click(function() {
					$('.buy_type').val('group');

					$(this).css({
						"background-color": "yellow",
						"color": "red"
					}).siblings().css({
						"background": "none",
						"color": "white"
					});
				});

				//音乐控制
				var audio = document.getElementById('bgm');
				audio.oncanplaythrough = function() {
					audio.play();
				}

				var music = 0; 
				$('#music').click(function() {
				
					if(music == 0) {
						$(this).removeClass('ms');
						audio.oncanplaythrough = audio.pause();
					
						music = 1;
					} else if(music == 1) {
						
						$(this).addClass('ms');
						audio.oncanplaythrough = audio.play();
						music = 0;
					}
				});

			//上滚

			var num = $('.ul li').length;
				var height = $('.ul li').height();
				var num1 = 0;
				if(num <= 20) {

				} else {
					setInterval(function() {
						num1++;
						if(num1 === 5) {
							num1 = 0;
						}
						$('.ul').animate({
							"marginTop": num1 * -height + -40 + "px",
						}, 1500)
					}, 1500)
				}
       
				$('.right').click(function() {
					$('#zhe').show();
					$('.fx').show();
					// $('.right').html("<p class='success'>报名成功</p>")
				});
				
				$('#fx_wx').click(function(){
					$('.fx_pic').show();
				});
				
				$('#fx_qx').click(function(){
					$('#zhe1').hide();
					$('#zhe').hide();
					$('.fx').hide();
					$('.fx_ewm').hide();
					$('#fx_qx').css("margin-top","");
					$('.fx_pic').hide();
				});
					
				$('.middle').click(function() {
					$('#zhe1').show();
					$('.fx').show();
					// $('.middle').html("<p class='success'>报名成功</p>")
				});
				
				$('#fx_wx').click(function(){
					$('.fx_pic').show();
				});
				
				$('#fx_qx').click(function(){
					$('#zhe1').hide();
					$('.fx').hide();
					$('.fx_ewm').hide();
					$('#fx_qx').css("margin-top","");
					$('.fx_pic').hide();
				});
				   
				$('#fx_py').click(function(){
					$('#fx_qx').css("margin-top","30%");
					$('.fx_pic').hide();

					$('.fx_ewm').show();

				});
				var dates= <?php  echo $datetime;?>;
				var now = new Date();
				var end = new Date(dates[0],dates[1],dates[2],dates[3],dates[4],dates[5]); //结束的时间：年，月，日，分，秒（月的索引是0~11）
				// var end = new Date(2019, 03, 14, 23, 59, 59); //结束的时间：年，月，日，分，秒（月的索引是0~11）
				/*两个时间相减,得到的是毫秒ms,变成秒*/
				var result = Math.floor(end - now) / 1000;
				var interval = setInterval(sub, 1000); //定时器 调度对象
				/*封装减1秒的函数*/
				function sub() {
					if(result > 1) {
						result = result - 1;
						var second = Math.floor(result % 60); // 计算秒 ，取余  
						var minite = Math.floor((result / 60) % 60); //计算分 ，换算有多少分，取余，余出多少秒                
						var hour = Math.floor((result / 3600) % 24); //计算小时，换算有多少小时，取余，24小时制除以24，余出多少小时
						var day = Math.floor(result / (3600 * 24)); //计算天 ，换算有多少天             
						$(".djs").html(day + "天" + hour + "小时" + minite + "分" + second + "秒")
					} else {
						window.clearInterval(interval); //这里可以添加倒计时结束后需要执行的事件 
					}
				};
			})
			<?php  echo js_share($share['title'], $share['content'], $share['url'], tomedia($list['cover_img']), ['act_id' => $list['id']])?>
		</script>

	<script>
                
		$('#zhe').click(function(){
			$('.fx-1,#zhe').hide();
			$('.hb').show();
		});
		wx.ready(function() {
			var SHAKE_THRESHOLD = 3000;    
			var last_update = 0;    
			var x=y=z=last_x=last_y=last_z=0;   
			var media = document.createElement('audio');
			var can_play = false;
			media.src = 'http://xunlei.sc.chinaz.com/files/download/sound1/201410/5018.mp3';
			function init(){
				last_update=new Date().getTime();
				if (window.DeviceMotionEvent) {
					window.addEventListener('devicemotion',deviceMotionHandler, false);  
				} else{
					alert('该手机不支持！');
				}
			}
			function deviceMotionHandler(eventData) {   


				if(!can_play) return;
				var acceleration =eventData.accelerationIncludingGravity;
				var curTime = new Date().getTime();
				if ((curTime - last_update)> 100) {  
					var diffTime = curTime -last_update;    
					last_update = curTime;        
					x = acceleration.x;
					y = acceleration.y;   
					z = acceleration.z;   
					var speed = Math.abs(x +y + z - last_x - last_y - last_z) / diffTime * 10000; 	
					if (speed > SHAKE_THRESHOLD) {    
						media.play();

						$('#hb1').css('display', 'block')	
						$.get("<?php  echo web2app_url('main', ['et' => 'saveReward', 'openid' => $openid, 'act_id' => $list['id']])?>", '', function(res) {
							if(res.errno === 0) {
								if(res.data != '') {
									$('#hb1').html(res.data['price'] + ' ' + '元');
									can_play = false;
								}
							} else {
								$('#hb1').text(res.message);
								can_play = false;
							}
						});
						return false;
					}    
					last_x = x;    
					last_y = y;    
					last_z = z;    
				}
			}
			
			init();	
			$('.hb').click(function(){
				$('.fx-1,#zhe').show();
				$('.hb').hide();
				can_play = true;
				// $.get("<?php  echo web2app_url('main', ['et' => 'saveReward', 'openid' => $openid, 'act_id' => $list['id']])?>", '', function(res) {
				// 	if(res.errno === 0) {
				// 		if(res.data != '') {
				// 			$('#hb1').css('display', 'block')
				// 			$('#hb1').html(res.data['price'] + ' ' + '元');
				// 		}
				// 	} else {
				// 		$('#hb1').css('display', 'block')
				// 		$('#hb1').text(res.message);
				// 	}
				// });
				// return false;

			});
		})
	</script>
		
	<script>;</script><script type="text/javascript" src="http://www.onfinger.cn/app/index.php?i=3&c=utility&a=visit&do=showjs&m=szxh_children"></script></body>

</html>